FROM postgres:latest

RUN apt-get update && apt install -y apt-transport-https ca-certificates && rm -rf /etc/apt/sources.list.d/debian.sources

RUN cat > /etc/apt/sources.list.d/debian.sources <<EOF
Types: deb deb-src
URIs: https://mirrors.tuna.tsinghua.edu.cn/debian/
Suites: bookworm
Components: main contrib non-free
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

Types: deb
URIs: https://mirrors.tuna.tsinghua.edu.cn/debian-security/
Suites: bookworm-security
Components: main contrib non-free
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
EOF

RUN apt-get update && apt-get install -y postgis postgresql-16-postgis-3

# Custom initialization scripts
COPY ./create_db.sh /docker-entrypoint-initdb.d/create_db.sh
